package com.borya.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public class SystemConfig extends PropertyUtils {

	private Logger log = Logger.getLogger(getClass());
	private static SystemConfig instance = new SystemConfig();

	private SystemConfig() {
		String path = "/conf/conf.properties";
		try (InputStream is = SystemConfig.class.getResourceAsStream("/application.properties")) {
			if (is != null) {
				Properties prop = load(is);
				final String profiles = prop.getProperty("spring.profiles.active");
				path = "/conf/conf-" + profiles + ".properties";
			}
		} catch (IOException ex) {
			// IGNORE
		}

		init(path, SystemConfig.class);
		log.debug("load properties file," + path);
	}

	public static final SystemConfig getInstance() {
		return instance;
	}
}
